﻿
using System ;
using System.Windows.Forms ;

using MskEdit.Dxf.Model ;


namespace MskEdit.Dxf.Frontend
{

    public class DxfObjectsTreeNode : TreeNode 
    {
        private DxfObjects dxfObjects_ ;
        
        
        public static DxfObjectsTreeNode TryFrom( DxfObjects dxfObjects, DxfObjectsTreeNode fallbackValue ) {
        
            if ( dxfObjects == null )
                return fallbackValue ;
                
            return new DxfObjectsTreeNode( dxfObjects ) ;
        }
        
        
        public DxfObjectsTreeNode( DxfObjects dxfObjects ) {
        
            dxfObjects_ = dxfObjects ;
            this.Text = "Objects " ;
                
            foreach ( var dxfEntitiy in dxfObjects_.Objects ) {
                
                DxfObjectTreeNode dxfEntitiyTreeNode = DxfObjectTreeNode.TryFrom( dxfEntitiy, null ) ;
                if ( dxfEntitiyTreeNode == null )
                    continue ;
                    
                this.Nodes.Add( dxfEntitiyTreeNode ) ;
            }
        }
    }
}
